package com.yhc.mq.mq.producer;

import com.aliyun.openservices.ons.api.OnExceptionContext;
import com.aliyun.openservices.ons.api.SendCallback;
import com.aliyun.openservices.ons.api.SendResult;
import lombok.extern.slf4j.Slf4j;

import java.time.LocalDateTime;

@Slf4j
public class SendAsyncMessage implements SendCallback {

    @Override
    public void onSuccess(SendResult sendResult) {
        log.info(">>>>> 【生产者】系统时间:[{}]异步发送消息MsgID=[{}]成功！", LocalDateTime.now(), sendResult.getMessageId());
    }

    @Override
    public void onException(OnExceptionContext onExceptionContext) {
        log.error(">>>>> 【生产者】系统时间:[{}]异步发送消息MsgID=[{}]失败, {}！", LocalDateTime.now(), onExceptionContext.getMessageId(), onExceptionContext.getException().getMessage());
    }


}
